package lambda;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import static java.util.stream.Collectors.groupingBy;

public class StreamDemo    {
    public static void main(String[] args) {

       /* *//**
         * 测试Stream流字符串列表操作
         *//*
        String str = "AJKHDAKDSHJAGASD";

        //转列表
        List<String> collect2 = Stream.of(str.split("")).collect(Collectors.toList());
        System.out.println(collect2.toString());
        //去重
        List<String> strList = Arrays.asList(str.split(""));
        List<String> collect = strList.stream().distinct().collect(Collectors.toList());
        System.out.println(collect);
        //排序
        final List<String> collect1 = strList.stream().sorted().collect(Collectors.toList());
        System.out.println(collect1.toString());
        //查找
        final String s = strList.stream().filter(v -> v.equals("A")).findAny().orElse("NA");




        //实体类列表分组
        Map<String, List<User>> collect3 = users.stream().collect(groupingBy(User::getSex));
        System.out.println(collect3.toString());

        //实体类列表排序
        List<User> collect4 = users.stream().sorted(Comparator.comparing(User::getAge)).collect(Collectors.toList());
        System.out.println(collect4.toString());

        //是否存在某值
        boolean isHave = users.stream().anyMatch(o -> o.getName().equals("张三"));


        //并行流
        List<User> collect5 = collect4.parallelStream().sorted(Comparator.comparing(User::getAge)).collect(Collectors.toList());
        System.out.println(collect5.toString());
*/
    }
}
